package com.hundsun.yr.universal.p2p.ui.activity;

import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.view.View.OnClickListener;

import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.library.eventbus.EventCenter;
import com.hundsun.yr.universal.library.netstatus.NetUtils.NetType;
import com.hundsun.yr.universal.p2p.ui.activity.base.BaseActivity;
import com.hundsun.yr.universal.p2p.utils.CommTool;
import com.hundsun.yr.universal.p2p.widget.InvestSuccessItemView;

/**
 * 借款成功
 *
 * @author tonglj
 */
public class LoanSuccessActivity extends BaseActivity implements OnClickListener {

    private InvestSuccessItemView itemViewMoney;//itemViewBeginDate,itemViewViewingDate;
    /**
     * 查看我的借款btn
     */
    private View mBtn;
    private String name = "";
    private String amount = "";

//    private LoanParam params;


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_loan_success:
                readyGo(MineLoanActivity.class);
                break;
            default:
                break;
        }
    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.act_loan_success;
    }

    @Override
    protected void getBundleExtras(Bundle extras) {
//        params = (LoanParam) extras.getSerializable(Extras.DATA);
        name = extras.getString("name");
        amount = extras.getString("amount");
    }

    @Override
    protected void initViewsAndEvents() {
        findViews();
        //设置导航栏颜色
        getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.color.primary_cl));
        toolbar_title.setText(R.string.loan_success);
        toolbar_title.setTextColor(getResources().getColor(R.color.white));
        mToolbar.setNavigationIcon(R.drawable.icon_back_light);
        mBtn.setOnClickListener(this);
        String productName = name;
        String showStr = mContext.getString(R.string.loan_apply_success, productName);
        SpannableStringBuilder builder = new SpannableStringBuilder(showStr);
        builder.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.primary_text)), showStr.indexOf(productName), showStr.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        itemViewMoney.setTitle(builder);

        itemViewMoney.setContent(mContext.getString(R.string._rmb, CommTool.roundingAmount(Double.valueOf(amount))));
        itemViewMoney.setImg(R.drawable.ic_borrowing_success);
        itemViewMoney.setLineVisible(View.GONE);
//		itemViewBeginDate.setImg(R.drawable.ic_borrowing_time);
//		itemViewBeginDate.setContent(HsDateUtils.timeformat(HsDateUtils.farmat_date_1, params.getLoanTime()));
//		itemViewBeginDate.setTitle(R.string.loan_time);
//		itemViewViewingDate.setTitle(R.string.examine_result);
//		itemViewViewingDate.setLineVisible(View.GONE);
//		itemViewViewingDate.setImg(R.drawable.ic_credit_result_time);
//		int checkPeriod = params.getCheckPeriod();
//		long d = checkPeriod*24*3600*1000;
//		itemViewViewingDate.setContent(HsDateUtils.timeformat(HsDateUtils.farmat_date_3, params.getLoanTime()+d));
    }

    private void findViews() {
        itemViewMoney = findView(R.id.investsuccess_iv_step1);
//		itemViewBeginDate = findView(R.id.investsuccess_iv_step2);
//		itemViewViewingDate = findView(R.id.investsuccess_iv_step3);
        mBtn = findView(R.id.btn_loan_success);
        //隐藏标题栏的横线
        findView(R.id.line_bottom).setVisibility(View.GONE);

    }

    @Override
    protected boolean isApplyKitKatTranslucency() {
        return true;
    }

    @SuppressWarnings("rawtypes")
    @Override
    protected void onEveComming(EventCenter eventCenter) {

    }

    @Override
    protected boolean isBindEventBusHere() {
        return false;
    }

    @Override
    protected View getLoadingTargetView() {
        return null;
    }

    @Override
    protected void onNetworkConnected(NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return true;
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return null;
    }

}
